package me.zhengjie.gas.dto;

import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;

@Data
@Entity
@Table(name = "code_first_migration")
public class CodeFirstMigrationDto {
	@Id
	@Column(name = "code_first_migration_uuid")
	private UUID codeFirstMigrationUUId;

	@Column(name = "file_name")
	private String fileName;

	@Column(name = "is_processed")
	private Boolean isProcessed;

	@Column(name = "is_success")
	private Boolean isSuccess;

	@Column(name = "error_log_message")
	private String errorLogMessage;

	@Column(name = "remarks")
	private String remarks;

	@Column(name = "is_default_script")
	private Boolean isDefaultScript;

	@Column(name = "created_by", insertable = false, updatable = false)
	private String createdBy;

	@Column(name = "created_ts", insertable = false, updatable = false)
	private LocalDateTime createdTs;

	@Column(name = "last_updated_by", insertable = false, updatable = false)
	private String lastUpdatedBy;

	@Column(name = "last_updated_ts", insertable = false, updatable = false)
	private LocalDateTime lastUpdatedTs;

	@PrePersist
	public void prePersist() {
		if (this.codeFirstMigrationUUId == null) {
			this.codeFirstMigrationUUId = UUID.randomUUID();
		}
	}
}
